package zz.app.ustbgsmanager.adapters;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.ArrayList;

import zz.app.ustbgsmanager.beans.querycourse.CourseInfo;
import zz.app.ustbgsmanager.beans.querycourse.CoursesInTerm;
import zz.app.ustbgsmanager.fragments.CourseFragment;

public class CourseFragmentPagerAdapter extends FragmentStatePagerAdapter {
    private final ArrayList<ArrayList<CourseInfo>> infos;
    private String[] days=new String[]{"周一","周二","周三","周四","周五","周六","周日"};
    public CourseFragmentPagerAdapter(FragmentManager fm, CoursesInTerm coursesInTerm) {
        super(fm);
        infos=coursesInTerm.getInfos();
    }

    @Override
    public Fragment getItem(int position) {
        CourseFragment fragment=new CourseFragment();
        fragment.setCourseInfos(infos.get(position));
        fragment.setDay(days[position]);
        return fragment;
    }

    @Override
    public int getCount() {
        return infos.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return days[position];
    }
}
